package com.trainingcloud.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.trainingcloud.exception.DAOException;

public class BaseDAO 
{
	protected Connection getConnection() throws DAOException
	{
		Connection connection = null;
		try 
		{
			Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
			connection = DriverManager.getConnection("proxool.tc");
			if (connection==null)
			{
				throw new DAOException("Can't connect to database");	
			}
			return connection;
		}
		catch (SQLException e)
		{
			throw new DAOException(e);
		}
		catch (ClassNotFoundException e)
		{
			throw new DAOException("Database driver class not found.", e);	
		}
	}
}
